Skip to content

Conversation

@simonLeary42
Copy link
Collaborator

@simonLeary42 simonLeary42 commented Sep 9, 2025

This replaces the white screen of death with a generic error message with a unique error identifier. #292

@simonLeary42
Copy link
Collaborator Author

simonLeary42 commented Sep 9, 2025

  • TODO record demo video

uncaught exception

1 file changed, 2 insertions(+)
webroot/admin/user-mgmt.php | 2 ++

modified   webroot/admin/user-mgmt.php
@@ -85,3 +85,5 @@ require $LOC_HEADER;
 
 <?php
 require $LOC_FOOTER;
+
+throw new RuntimeError("deleteme");
Screen.Recording.2025-09-10.at.8.53.47.AM.mov

caught exception

1 file changed, 6 insertions(+)
resources/init.php | 6 ++++++

modified   resources/init.php
@@ -141,3 +141,9 @@ $LOC_HEADER = __DIR__ . "/templates/header.php";
 $LOC_FOOTER = __DIR__ . "/templates/footer.php";
 
 register_shutdown_function(array("UnityWebPortal\lib\UnitySite", "shutdown"));
+
+try {
+    throw new RuntimeException("deleteme");
+} catch(RuntimeException) {
+    echo "caught";
+}
Screen.Recording.2025-09-10.at.9.10.04.AM.mov

redirect

Screen.Recording.2025-09-10.at.9.16.48.AM.mov

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements a generic error handling mechanism to replace the white screen of death with user-friendly error messages that include unique error identifiers for debugging purposes.

  • Adds a shutdown function to catch fatal errors and display a generic error message
  • Updates error handling methods to clear last error to prevent interference
  • Simplifies SSO error handling by removing explicit try-catch and letting the shutdown function handle errors

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
resources/lib/UnitySite.php Adds shutdown function for error handling and clears errors in badRequest/forbidden methods
resources/init.php Registers the shutdown function and removes explicit SSO error handling
test/functional/InvalidEPPNTest.php Updates test to expect SSOException instead of PhpUnitNoDieException

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@simonLeary42
Copy link
Collaborator Author

simonLeary42 commented Sep 9, 2025

  • TODO fix errors on front page in dev environment so that demo will work as intended

self::errorLog("internal server error", json_encode($e));
echo "
<h1>An internal server error has occurred.</h1>
<p>Please notify a Unity admin. Error ID: $errorid.</p>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not put the support email here like in the old message?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because UnityConfig isn't exposed inside UnitySite

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason it can't be?

@simonLeary42 simonLeary42 force-pushed the global-error-handler branch 4 times, most recently from 6a7f164 to 8312ea2 Compare September 10, 2025 20:23
@simonLeary42
Copy link
Collaborator Author

support email included:

image image

@simonLeary42 simonLeary42 marked this pull request as ready for review September 10, 2025 20:27
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@simonLeary42
Copy link
Collaborator Author

UnitySite::forbidden works as expected with its error_clear_last():

image

@simonLeary42 simonLeary42 merged commit 4307a9d into main Sep 10, 2025
2 checks passed
@simonLeary42 simonLeary42 deleted the global-error-handler branch September 10, 2025 20:34
@simonLeary42
Copy link
Collaborator Author

fcb5437

@simonLeary42
Copy link
Collaborator Author

d9e2ef9

@simonLeary42
Copy link
Collaborator Author

5c36b54

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants